import { IncomingHttpHeaders } from 'http';
import { productid, systemid } from '../../atom/config';

import query from '@dfeidao/atom-nodejs/db/query';
interface Message {
	filter: {
		knowledge_name: string
		staff_no: string
	};
	// cookie: {
	// 	uk: string;
	// 	[key: string]: string
	// };
	// urls: {
	// 	base: string;
	// 	origin: string;
	// 	url: string;
	// };
	// query: {};
	// params: {};
	// headers: {};
	// captcha: string;
}

// interface IWebResult {
// 	data: unknown;
// 	cookie?: {
// 		[name: string]: string;
// 	} | null;
// 	content_type?: string;
// 	headers?: {
// 		[key: string]: string;
// 	};
// 	attachment?: string;
// 	redirect?: string;
// 	status_code?: number;
// }

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
	// 技术类的模糊查询
	const q = query(action_id, session_id, systemid);
	q.prepare('knowledge_base_2', ['knowledge_no','knowledge_no', 'knowledge_name', 'knowledge_explain', 'create_time'],
	{ productid, knowledge_class: 2,creater_no:message.filter.staff_no,
	knowledge_name: { $like: ("%" + message.filter.knowledge_name + "%") } }, 20, 1, [], []);
	const [res] = await q.exec();
	return { res };
}
